﻿var InsertSwafImage = function()
{
	this.Name = 'SwafImage' ;
}

InsertSwafImage.prototype.Execute = function()
{
	var img = window.showModalDialog("/popups/InsertImagePopup.aspx?T=Insert Image",null,"dialogWidth:750px;dialogHeight:500px;center:yes; resizable: yes; help: no");
	if(img != false && img != null)
	{
		var typ = img[0];
		var width = img[1];
		var height = img[2];
		var mainMedia = img[3];
		var srcImg = img[4];
		//alert(typ + "," + width + "," + height + "," + mainMedia + "," + srcImg);
		if(mainMedia.substr(mainMedia.length-4) == ".wmv")
		{
			var x = '<div title="click to play video" onclick="showMediaClip(this,\'' + mainMedia + '\',' + width + ',' + height +
			 ')" style="cursor: pointer"><img alt="" src="' + srcImg + '" /></div>';
			 //alert(x);
			FCK.InsertHtml(x);
		}	
		else
			FCK.InsertHtml("<img src='" + mainMedia + "' />");
	}
}

InsertSwafImage.prototype.GetState = function()
{
	return FCK.GetNamedCommandState( 'Image' ) ;
}

FCKCommands.RegisterCommand('SwafImage', new InsertSwafImage());

// Create the Insert Swaf Image toolbar button.
var insertSwafImg = new FCKToolbarButton( 'SwafImage', FCKLang.InsertImageLbl, FCKLang.InsertImage, null, false, true, 37 ) ;
FCKToolbarItems.RegisterItem( 'SwafImage', insertSwafImg ) ;
